#pragma once
#include "core/IJsonSerializable.h"

/// <summary>
/// The base document, which provides the following features:
/// - read/write json files
/// </summary>
class BaseDocument : public IJsonSerializable
{
public:
    BaseDocument();
    BaseDocument(const QString& fullPath);
    ~BaseDocument();

public: // IJsonSerializable
    void fromJson(const QJsonObject& src, QStringList& errorList) override;
    QJsonObject toJson() const override;

public:
    virtual bool load();
    virtual bool save();
    virtual bool saveTo(const QString& fullPath);

public:
    virtual QString filename() const { return filename_; }
    void setFilename(const QString& value) { filename_ = value; }

protected:
    QString filename_ = "";
};
